<?php
class GroundVo extends SzAbstractMySqlVo
{

    private $userId;
    private $gridId;
    private $layer1Type;
    private $layer1;
    private $layer2Type;
    private $layer2;
    private $layer3Type;
    private $layer3;

    /**
     * Initialize GroundVo.
     *
     * @param $userId
     * @param $gridId
     * @param $layer1Type
     * @param $layer1
     * @param $layer2Type
     * @param $layer2
     * @param $layer3Type
     * @param $layer3
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return GroundVo
     */
    public function __construct($userId, $gridId, $layer1Type, $layer1, $layer2Type, $layer2, $layer3Type, $layer3, $isInsert = false) {
        $this->userId = $userId;
        $this->gridId = $gridId;
        $this->layer1Type = $layer1Type;
        $this->layer1 = $layer1;
        $this->layer2Type = $layer2Type;
        $this->layer2 = $layer2;
        $this->layer3Type = $layer3Type;
        $this->layer3 = $layer3;

        $this->isInsert = $isInsert;
        $this->voClassName = 'GroundVo';
        $this->ormName = 'Ground';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'gridId' => $this->getGridId(),
            'layer1Type' => $this->getLayer1Type(),
            'layer1' => $this->getLayer1(),
            'layer2Type' => $this->getLayer2Type(),
            'layer2' => $this->getLayer2(),
            'layer3Type' => $this->getLayer3Type(),
            'layer3' => $this->getLayer3(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'gridId' => $this->getGridId(),
            'layer1Type' => $this->getLayer1Type(),
            'layer1' => $this->getLayer1(),
            'layer2Type' => $this->getLayer2Type(),
            'layer2' => $this->getLayer2(),
            'layer3Type' => $this->getLayer3Type(),
            'layer3' => $this->getLayer3(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getGridId(),
            $this->getLayer1Type(),
            $this->getLayer1(),
            $this->getLayer2Type(),
            $this->getLayer2(),
            $this->getLayer3Type(),
            $this->getLayer3(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getGridId()
    {
        return $this->gridId;
    }

    public function setGridId($val)
    {
        $this->saveColumnStatus(1, $this->gridId);
        $this->gridId = $val;
    }

    public function getLayer1Type()
    {
        return $this->layer1Type;
    }

    public function setLayer1Type($val)
    {
        $this->saveColumnStatus(2, $this->layer1Type);
        $this->layer1Type = $val;
    }

    public function getLayer1()
    {
        return $this->layer1;
    }

    public function setLayer1($val)
    {
        $this->saveColumnStatus(3, $this->layer1);
        $this->layer1 = $val;
    }

    public function getLayer2Type()
    {
        return $this->layer2Type;
    }

    public function setLayer2Type($val)
    {
        $this->saveColumnStatus(4, $this->layer2Type);
        $this->layer2Type = $val;
    }

    public function getLayer2()
    {
        return $this->layer2;
    }

    public function setLayer2($val)
    {
        $this->saveColumnStatus(5, $this->layer2);
        $this->layer2 = $val;
    }

    public function getLayer3Type()
    {
        return $this->layer3Type;
    }

    public function setLayer3Type($val)
    {
        $this->saveColumnStatus(6, $this->layer3Type);
        $this->layer3Type = $val;
    }

    public function getLayer3()
    {
        return $this->layer3;
    }

    public function setLayer3($val)
    {
        $this->saveColumnStatus(7, $this->layer3);
        $this->layer3 = $val;
    }

    /**
     * Set the value of "setLayer{$layerId}Type".
     *
     * @param int $layerId
     * @param int $val
     * @return int
     */
    public function setLayerType($layerId, $val)
    {
        $this->validateLayerId($layerId);
        $func = "setLayer{$layerId}Type";
        return $this->$func($val);
    }

    /**
     * Get the value of "getLayer{$layerId}Type".
     *
     * @param int $layerId
     * @return int
     */
    public function getLayerType($layerId)
    {
        $this->validateLayerId($layerId);
        $func = "getLayer{$layerId}Type";
        return $this->$func();
    }

    /**
     * Set the value of "setLayer{$layerId}".
     *
     * @param int $layerId
     * @param int $val
     * @return mixed
     */
    public function setLayer($layerId, $val)
    {
        $this->validateLayerId($layerId);
        $func = "setLayer{$layerId}";
        return $this->$func($val);
    }

    /**
     * Get the value of "getLayer{$layerId}".
     *
     * @param int $layerId
     * @return mixed
     */
    public function getLayer($layerId)
    {
        $this->validateLayerId($layerId);
        $func = "getLayer{$layerId}";
        return $this->$func();
    }

    /**
     * Validate layer id is a number and is 1 | 2 | 3.
     *
     * @param int $layerId
     * @throws SzException 20102
     * @return void
     */
    private function validateLayerId($layerId)
    {
        $layerId += 0;
        if ($layerId && (!is_numeric($layerId) || $layerId < 1 || $layerId > 3 || is_float($layerId))) {
            throw new SzException(20160, $layerId);
        }
    }
}